require 'sketchup.rb'

class MakeTempGC

    def initialize()
    end

    def makeAGroup
        width=4; height=4; depth=4;
        model = Sketchup.active_model
        #//model.start_operation $exStrings.GetString("Create Box")
        entities = model.active_entities

        # If you wanted the box to be created as simple top level entities
        # rather than a Group, you could comment out the following two lines.
        group = entities.add_group
        entities = group.entities

        pts = []
        pts[0] = [0, 0, 0]
        pts[1] = [width, 0, 0]
        pts[2] = [width, depth, 0]
        pts[3] = [0, depth, 0]
        base = entities.add_face pts
        height = -height if( base.normal.dot(Z_AXIS) < 0 )

        # Now we can do the pushpull
        base.pushpull height

        # Now we are done and we can end the operation
        #//model.commit_operation
        return group
    end

end # class MakeTempGC

$test = MakeTempGC.new
$myGroup = $test.makeAGroup()
$myComponent = $test.makeAGroup.to_component
puts("MakeTempGC is loaded")

sel = Sketchup.active_model.selection
sel.clear
sel.add $myGroup
# update shadow menus
sel.clear
sel.add $myComponent
# update shadow menus
sel.clear
$myGroup.erase!
$myComponent.erase!

